<template>
	<view class="content">
		<!-- 基本信息 -->
		<view class="formBox basic-info">
			<view class="f-c-sb title">
				<view>基本信息</view>
			</view>
			<view class="f-c-sb">
				<view class="label">微信昵称</view>
				<view class="value">{{ detail.customer.vxName }}</view>
			</view>
			<view class="f-c-sb">
				<view class="label">联系电话</view>
				<view class="value">{{ detail.customer.contactPhone }}</view>
			</view>
			<view class="f-c-sb">
				<view class="label">注册方式</view>
				<view class="value">{{ detail.customer.memberSource|memberSource}}</view>
			</view>
			<view class="f-c-sb">
				<view class="label">注册时间</view>
				<view class="value">{{ detail.customer.createTime }}</view>
			</view>
			<view class="f-c-sb">
				<view class="label">最近访问时间</view>
				<view class="value">{{ detail.customer.lastLoginTime }}</view>
			</view>
		</view>


		<!-- 优惠券 -->
		<view class="formBox card-info" @click="goCoupons">
			<view class="f-c-sb">
				<view class="tit">优惠券</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
			<view class="f-fs-sa">
				<view class="card-item">
					<view>待使用</view>
					<view class="card-num">{{ detail.coupon.notUsed }}张</view>
				</view>
				<view class="card-item">
					<view>已使用</view>
					<view class="card-num">{{ detail.coupon.used }}张</view>
				</view>
				<view class="card-item">
					<view>已过期</view>
					<view class="card-num">{{ detail.coupon.expired }}张</view>
				</view>
			</view>
		</view>
		<!-- 活动订单 -->
		<view class="formBox card-info" @click="goActivity">
			<view class="f-c-sb">
				<view class="tit">活动订单</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
			<view class="f-fs-sa">
				<view class="card-item">
					<view>可使用</view>
					<view class="card-num">{{ detail.activityOrder.notUsed }}张</view>
				</view>
				<view class="card-item">
					<view>已使用</view>
					<view class="card-num">{{ detail.activityOrder.used }}张</view>
				</view>
				<view class="card-item">
					<view>已过期</view>
					<view class="card-num">{{ detail.activityOrder.expired }}张</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		customerDetail
	} from '@/api/marketingB-helper.js';

	export default {
		data() {
			return {
				detail: {},
				customerNo: ''
			};
		},
		onLoad(option) {
			this.customerNo = JSON.parse(option.param).customerNo;
			this.getDetail();
		},
		methods: {
			getDetail() {
				customerDetail(this.customerNo).then(res => {
					this.detail = res.data;
				});
			},
			goCoupons() {
				this.$navigateTo('./coupons', {
					customerNo: this.customerNo
				});
			},
			goActivity() {
				this.$navigateTo('./sales', {
					customerNo: this.customerNo
				});
			}
			
		}
	};
</script>

<style lang="less">
	.content {
		padding: 20rpx 0;
		background: #f5f5f5;

		.basic-info {
			padding-top: 34rpx;

			.edit {
				color: #177fff;
				font-weight: bold;
			}

			.value {
				font-weight: bold;
				font-size: 28rpx;
			}

			.label {
				font-size: 28rpx;
			}

			.f-c-sb:not(:first-child) {
				padding: 30rpx 0;
				border-bottom: 1px solid #ededed;
			}

			.f-c-sb:last-child {
				border: none;
				padding-bottom: 15rpx;
			}
		}

		.car-info {
			padding-top: 34rpx;
			color: #131313;

			.tit {
				font-size: 28rpx;
				font-weight: bold;
			}

			.car-info-item {
				border-bottom: 1px solid #ededed;
				padding-bottom: 24rpx;

				.car-sign {
					background: #177fff;
					padding: 4rpx 8rpx;
					display: inline-block;
					color: #fff;
					font-size: 24rpx;
					border-radius: 6px;
					margin-top: 22rpx;
				}

				.car-info-name {
					font-size: 28rpx;
					font-weight: bold;
					line-height: 60rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}

				.car-number {
					font-size: 24rpx;
					line-height: 1;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}

			.car-info-item:last-child {
				border: none;
			}
		}

		.card-info {
			padding-top: 34rpx;
			color: #131313;
			font-size: 26rpx;

			.tit {
				font-size: 28rpx;
				font-weight: bold;
			}

			.f-fs-sa {
				padding: 20rpx 0;

				.card-item {
					flex: 1;
					text-align: center;
					border-right: 1px solid #e5e5e5;
				}

				.card-num {
					color: #ff6738;
					font-size: 28rpx;
					padding-top: 10rpx;
				}

				.card-item:last-child,
				.card-item-none {
					border: none;
					flex: 1;
					text-align: center;
				}
			}
		}
	}
</style>
